<!--
 * @Description: 自定义指令
 * @Author: zzj
 * @Date: 2021-10-12 11:28:11
 * @LastEditors: zzj
 * @LastEditTime: 2021-10-12 20:28:21
-->
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>自定义指令</title>
	<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.js"></script>
</head>
<body>
	<div id="app">
		<input type="text">
		<input type="text" v-focus:name="msg">
	</div>
	<script>
		/*
		//全局注册
		Vue.directive('focus',{
			inserted:function(el){
				el.focus();   //聚焦
			}
		})
		*/
		new Vue({
			el:"#app",
			//局部注册
			directives:{
				focus:{
					inserted:function(el,binding){
						console.log(binding);
						console.log(binding.arg);
						console.log(binding.value);
						el.focus();
					}
				}
			},
			data:{
				msg:"hello 动态组件"
			}
		})
	</script>
</body>
</html>